<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Bentham|Playfair+Display|Raleway:400,500|Suranna|Trocchi"
        rel="stylesheet">
    <link rel="stylesheet" href="./CSS/all.css">
    <title>news</title>
</head>

<body>
    <div class="container">
        <div class="header">
            <h1>每日新闻</h1>
        </div>
        <div class="search">
            <select class="selectMethod">
                <option checked>选择你的请求方式</option>
                <option value="axios">axios</option>
                <option value="jq">ajax</option>
                <option value="js">原生ajax</option>
            </select>
        </div>
        <div class="newsTop">
        </div>

    </div>

    <style>
        * {
            padding: 0px;
            margin: 0px;
        }

        .wrapper {
            height: 100px;
            width: 98%;
            margin: 0 auto;
            margin-top: 30px;
            margin-bottom: 30px;
            border-radius: 7px 7px 7px 7px;
            border: 1px solid black;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            position: relative;
        }

        .wrapper-after {
            width: 100%;
            height: 10px;
        }

        .wrapper img {
            display: block;
            max-width: 50%;
            height: auto;
        }

        .wrapper-after::after {
            /* width: 100%;
            height: 10px;
            content: '';
            display: inline-block;
            background-image: url(./Image/向下.png);
            background-size: 10px;
            background-position: center; */
            content: '';
            display: inline-block;
            width: 100%;
            height: 20px;
            background-size: 20px;
            background-image: url(./Image/向下.png);
            background-repeat: no-repeat;
            background-position: center;
            position: absolute;
            bottom: 0px;
        }

        .product-img {
            float: left;
            height: 100%;
            width: 15%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .product-img img {
            border-radius: 7px 0 0 7px;
            max-width: 80%;
            max-height: 80%;
        }

        .product-info {

            height: 100%;
            width: 100%;
            border-radius: 0 7px 10px 7px;
            background-color: #ffffff;
        }

        .product-text {
            height: 100%;
            width: 100%;
        }

        .product-text h1 {
            font-size: 10px;
            color: #474747;
        }

        .product-text h2 {
            font-size: 13px;
            font-family: 'Raleway', sans-serif;
            font-weight: 400;
            text-transform: uppercase;
            color: #d2d2d2;
            letter-spacing: 0.2em;
        }

        .product-price-btn {
            height: 30%;
            width: 100%;
            position: relative;
        }

        .product-price-btn p {
            display: inline-block;
            position: absolute;
            top: -13px;
            height: 50px;
            font-family: 'Trocchi', serif;
            margin: 0 0 0 38px;
            font-size: 28px;
            font-weight: lighter;
            color: #474747;
        }

        span {
            display: inline-block;
            height: 50px;
            font-family: 'Suranna', serif;
            font-size: 34px;
        }
        .content img{
            display: block;
            max-width: 200px;
        }

        .product-price-btn button {
            float: right;
            display: inline-block;
            height: 50px;
            width: 176px;
            margin: 0 40px 0 16px;
            box-sizing: border-box;
            border: transparent;
            border-radius: 60px;
            font-family: 'Raleway', sans-serif;
            font-size: 14px;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.2em;
            color: #ffffff;
            background-color: #9cebd5;
            cursor: pointer;
            outline: none;
        }

        .product-price-btn button:hover {
            background-color: #79b0a1;
        }

        .card-after {
            width: 100%;
            height: 20px;
            background: #fff;
            border-radius: 0 0 25px 25px;
            position: absolute;
            bottom: 0px;

        }
        .card-after img {
            display: block;
            width: 20px;
            height: 20px;
            margin: auto;
        }

        .card .allImg {
            display: block;
            margin: auto;
           max-height: 200px;
           border-radius: 10px;
           padding-top: 10px;
           padding-bottom: 10px;
        }

        .card {
            height: 400px;
            width: 90%;
            margin: 0 auto;
            background-color: white;
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
            border-radius: 4px;

            margin-bottom: 20px;
            position: relative;
            overflow: hidden;
        }

        .card .title {
            width: 100%;
            height: 50px;
            font-size: 20px;
            font-weight: 1000;
            line-height: 50px;
            Text-overflow:ellipsis
        }

        .card span {
            font-size: 7px;
            color: #000000;
        }
    </style>
    <script type="module">
        import * as method from './JS/everyMethod.js'
        window.onload = function () {
            $('.pullDown').click(function () {
                let discuss = this.children[0].src
                console.log(discuss)
                if (discuss.includes('向下')) {
                    this.parentNode.style.height = 'auto'
                    this.children[0].src = "./Image/向上.png"
                } else {
                    this.parentNode.style.height = '100px'
                    this.children[0].src = "./Image/向下.png"
                }
            })
        }

        $('.selectMethod').change(function (event) {

            let url = `http://jisunews.market.alicloudapi.com/news/get?num=100&channel=头条&start=0`
            let value = event.target.value
            if (value == 'jq') {
                method.xmlFindJq('GET', url, jqXhrGetData)
            } else if (value == 'axios') {
                method.axiosFind('GET', url, axiosGetData)
            } else if (value == 'js') {
                method.xmlFindJs('GET', url, jsXhrGetData)
            }

        })
        function axiosGetData(response) {
            exaggerate(response.data)


        }
        function jqXhrGetData(response) {
            exaggerate(response)

        }
        function jsXhrGetData(response) {
            exaggerate(JSON.parse(response))

        }

        function exaggerate(response) {

            console.log(response)
            let news=response.result.list
            let strList;
            for (let i = 0; i < news.length; i++) {
                let str =   `
        <div class="card">
        <img class="allImg" src="${news[i].pic}" alt="" />
        <div>
            <p>${news[i].time}</p>
            <span class="content"> ${news[i].content}</span>
        </div>
        <div class="card-after">
            <img class="imgDown" style="display: block;" src="./Image/向下.png">
            <img class="imgUp" style="display: none;" src="./Image/向上.png">
        </div>
    </div>
        `
                strList += str

            }
            $('.newsTop').append(strList)
            exegudateClick()
        }

        function exegudateClick() {
            $('.card-after').click(function () {
                if (this.children[0].style.display == 'block') {
                    this.children[0].style.display = 'none'
                    this.children[1].style.display = 'block'
                    this.parentElement.style.height = 'auto'
                } else {
                    this.children[1].style.display = 'block'
                    this.children[1].style.display = 'none'
                    this.parentElement.style.height = '400px'
                }
            })
        }



    </script>
</body>

</html>